package com.shengyuan.manage_os.old.ying.erpm.device;

import com.shengyuan.manage_os.R;

import android.app.Activity;
import android.media.MediaPlayer;
import android.media.MediaPlayer.OnErrorListener;
import android.net.Uri;
import android.os.Bundle;
import android.widget.MediaController;
import android.widget.VideoView;

public class PlayerVideo extends Activity {

	private VideoView videoView;
	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.controls_player_video);
		videoView = (VideoView) findViewById(R.id.videoview);

		Bundle bundle = getIntent().getExtras();
		String path = bundle.getString("path");
		if (path.equals("")) {
			finish();
		}else{
			MediaController mc = new MediaController(this); 
	
			videoView.setOnErrorListener(videoErrorListener);
			videoView.setMediaController(mc);
			//videoView.setVideoPath(path);  
			videoView.setVideoURI(Uri.parse(path));
			videoView.requestFocus(); 
			videoView.start();
		}
	}

	public OnErrorListener videoErrorListener = new OnErrorListener() {
		
		@Override
		public boolean onError(MediaPlayer mp, int what, int extra) {
			return true;
		}
	};
	@Override
	protected void onDestroy() {
		super.onDestroy();
		videoView.stopPlayback();
		videoView = null;
	}

}
